﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WorkDAL
{
    public class MenuDataAccess
    {
        WorkerDataContext workContext = new WorkerDataContext();

        public static MenuDataAccess Instance()
        {
            return new MenuDataAccess();
        }

        public List<tbMenu> GetMenuLevel1()
        {
            var menuItemList = from c in this.workContext.tbMenus
                               where c.MenuLevel == 1
                               orderby c.Group, c.MenuLevel
                               select c;

            return menuItemList.ToList();
        }

        public List<tbMenu> GetMenuLevel2(string groupmenu)
        {
            var menuItemList = from c in this.workContext.tbMenus
                               where c.Group == groupmenu
                               orderby c.Group, c.MenuLevel
                               select c;

            return menuItemList.ToList();
        }

        public List<tbMenu> GetMenu(int menuId)
        {
            var menuItemList = from c in this.workContext.tbMenus
                               where c.Id == menuId
                               orderby c.Group, c.MenuLevel
                               select c;

            return menuItemList.ToList();
        }
    }
}
